home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / stdio / bug1.c < prev    next >
C/C++ Source or Header  |  1992-04-09  |  572b  |  29 lines

  1. #include <ansidecl.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int
  6. DEFUN_VOID(main)
  7. {
  8.   char *bp;
  9.   size_t size;
  10.   FILE *stream;
  11.   int lose = 0;
  12.  
  13.   stream = open_memstream (&bp, &size);
  14.   fprintf (stream, "hello");
  15.   fflush (stream);
  16.   printf ("buf = %s, size = %d\n", bp, size);
  17.   lose |= size != 5;
  18.   lose |= strncmp (bp, "hello", size);
  19.   fprintf (stream, ", world");
  20.   fclose (stream);
  21.   printf ("buf = %s, size = %d\n", bp, size);
  22.   lose |= size != 12;
  23.   lose |= strncmp (bp, "hello, world", 12);
  24.  
  25.   puts (lose ? "Test FAILED!" : "Test succeeded.");
  26.  
  27.   return lose;
  28. }
  29.